package com.laguille.games.monopoly.commons.event;

import org.apache.commons.lang.Validate;

import com.laguille.games.monopoly.commons.player.Player;
import com.laguille.games.monopoly.commons.property.Property;

/**
 * When a player lands on a unoccupied property.
 *
 */
public class EmptyPropertyEvent extends Event {

	private final Player player;
	private final Property property;
	
	public EmptyPropertyEvent(Player player, Property property) {
		Validate.notNull(player);
		Validate.notNull(property);
		this.player = player;
		this.property = property;
	}

	public Player getPlayer() {
		return player;
	}

	public Property getProperty() {
		return property;
	}

	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((player == null) ? 0 : player.hashCode());
		result = prime * result
				+ ((property == null) ? 0 : property.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EmptyPropertyEvent other = (EmptyPropertyEvent) obj;
		if (player == null) {
			if (other.player != null)
				return false;
		} else if (!player.equals(other.player))
			return false;
		if (property == null) {
			if (other.property != null)
				return false;
		} else if (!property.equals(other.property))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "EmptyPropertyEvent [player=" + player + ", property="
				+ property + "]";
	}

}
